/*
 * FileName BitmapSource.h
*/

#ifndef __DEEP_ZOOM_IMAGE_BITMAPSOURCE_H__
#define __DEEP_ZOOM_IMAGE_BITMAPSOURCE_H__

#include "cairo/cairo.h"
#include "ImageSource.h"
#include "Context.h"

namespace DeepZoomImage
{
	class BitmapSource : public ImageSource
	{
	private:
		gpointer data;
		bool own_data; // if true, we free in the dtor.
	protected:
		cairo_surface_t *image_surface;
		Context::Cache cache;

		BitmapSource ();
		virtual ~BitmapSource ();

	public:
		 gint32 m_PixelWidth;
		 gint32 m_PixelHeight;
		 gint32 imageStride;

		/* @GenerateManagedEvent=false */
		const static int PixelDataChangedEvent;

		virtual gint32 GetPixelWidth ();
		virtual void SetPixelWidth (gint32 width);
		virtual gint32 GetPixelHeight ();
		virtual void SetPixelHeight (gint32 height);

		gpointer GetBitmapData ();
		void SetBitmapData (gpointer data, bool own);

		virtual void Invalidate ();

		virtual cairo_surface_t *GetImageSurface () { return image_surface; }
		MoonSurface *GetSurface (Context *ctx);
		virtual void OnIsAttachedChanged (bool value);
	};
}
#endif /*__DEEP_ZOOM_IMAGE_BITMAPSOURCE_H__*/